#define FoRecall_Variable

#include "userDef.h"

void FoRecallAct(void) /* called in main.c */
{
    if (stat_FoRecall != 0)
    {
        if (stat_FoRecall == 1)
        {
            set_power(ON);
            set_mode(MODECOOL);
            set_fanStep(FANLEVEL7);
            set_tartemp(160, 610);

            set_verSw(0x02);
            set_horSw(0x00);
        }
        else if (stat_FoRecall == 2)
        {
            set_power(OFF);

            set_mode(MODEAUTO);

            set_tartemp(250, 770);

            set_fanStep(FANAUTO);

            set_verSw(0x01);
            set_horSw(0x01);
        }

        set_light(0);// 遥控器协议里面 0是开屏显，1是关 屏显
        set_sleep(OFF);
        set_health(ON);
        set_dryer(OFF);
        set_heater(OFF);
        set_eco(OFF);
        set_lowheat(OFF);

        set_timerOn(0);
        set_timerOff(0);

        temp.IFeel = 0;

        stat_FoRecall = 0;

#ifdef CTRL_485
        update_wireCtrl = 2;
#endif
    }

    if (f_FoRecall == 1)
    {
        if (f_RoomErrQT == ON)
        {
            f_RoomErr_FoRecall = ON;
            f_RoomErrQT = OFF;
        }

        if (f_TubeErrQT == ON)
        {
            f_TubeErr_FoRecall = ON;
            f_TubeErrQT = OFF;
        }

        if (f_JumpErrQT == ON)
        {
            f_JumpErr_FoRecall = ON;
            f_JumpErrQT = OFF;
        }
    }
    else
    {
        if (f_RoomErr_FoRecall == ON)
        {
            f_RoomErr_FoRecall = OFF;
            f_RoomErrQT = ON;
        }

        if (f_TubeErr_FoRecall == ON)
        {
            f_TubeErr_FoRecall = OFF;
            f_TubeErrQT = ON;
        }

        if (f_JumpErr_FoRecall == ON)
        {
            f_JumpErr_FoRecall = OFF;
            f_JumpErrQT = ON;
        }
    }
}

void FoRecallSet(void) /* called in iRemote.c */
{
    if (f_FoRecall == 0)
    {
        /* 上电5分钟内，制冷模式开机，目标温度16  */
        if (PowerOnMin <= 4 && e_mode.set == MODECOOL && b_power.set == ON && l_tarTemp_C.set[e_mode.set] == 160)
        {
            if (timer_FoRecall_Set == 0)
            {
                if (f_chg_light == TRUE)
                {
                    timer_FoRecall_Set = 30;
                    count_FoRecall_Set = 1;
                }
            }
            else
            {
                if (f_chg_light == TRUE)
                {
                    count_FoRecall_Set++;
                }
                else
                {
                    timer_FoRecall_Set = 0;
                    count_FoRecall_Set = 0;
                }
            }

            if (count_FoRecall_Set >= 6)
            {
                timer_FoRecall_Set = 0;
                count_FoRecall_Set = 0;

                timer_FoRecall_Run = 0;
                f_FoRecall = 1;
                stat_FoRecall = 1;
            }
        }
        else
        {
            timer_FoRecall_Set = 0;
            count_FoRecall_Set = 0;
        }
    }
    else
    {
        f_FoRecall = 0;
    }
}

void FoRecallTime(void) /* called in systime.c per 1s */
{
    if (f_FoRecall == 1)
    {
        if (timer_FoRecall_Run < 1500)
        {
            timer_FoRecall_Run++;

            if ((f_GasLeakErr == ON && (OutSafeErr0 != 0 || timer_FoRecall_Run >= 300)) || timer_FoRecall_Run >= 1500)
            {
                f_FoRecall = 0;
                timer_FoRecall_Run = 0;
                stat_FoRecall = 2;
            }
        }
    }
    else
    {
        timer_FoRecall_Run = 0;
    }
}
